﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using BusinessObjects.BO_GetObjects;
using System.IO;
using System.Xml;

public partial class Pages_RegistService : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            loadData();
            LoadRightModule();
        }
    }

    private void loadData()
    {
        try
        {
            string fname = Server.MapPath("~/upload/xml/regist.xml");
            if (File.Exists(fname))
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(fname);
                XmlNode root = doc.DocumentElement;
                XmlNodeList list = root.ChildNodes;
                persional_title.InnerText = list.Item(0).ChildNodes.Item(0).InnerText;
                persional_price.InnerText = list.Item(0).ChildNodes.Item(1).InnerText;
                personal_intro.InnerHtml = list.Item(0).ChildNodes.Item(2).InnerText;
                personal_benefit.InnerHtml = list.Item(0).ChildNodes.Item(3).InnerText;
                professional_title.InnerText = list.Item(1).ChildNodes.Item(0).InnerText;
                professional_price.InnerText = list.Item(1).ChildNodes.Item(1).InnerText;
                professional_intro.InnerHtml = list.Item(1).ChildNodes.Item(2).InnerText;
                professional_benefit.InnerHtml = list.Item(1).ChildNodes.Item(3).InnerText;
            }
        }
        catch (Exception ex)
        {

        }
    }

    protected void LoadRightModule()
    {
        DataTable objDT = null;
        objDT = BO_Module.SelectLocation(3);
        for (int i = 0; i < objDT.Rows.Count; i++)
        {
            if (objDT.Rows[i]["type_id"].ToString() == "3")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucCustomSearch.ascx");
                Controls_ucCustomSearch control = (Controls_ucCustomSearch)controls;
                plHolderRight.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "4")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucRegistService.ascx");
                Controls_ucRegistService control = (Controls_ucRegistService)controls;
                plHolderRight.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "5")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucSupport.ascx");
                Controls_ucSupport control = (Controls_ucSupport)controls;
                plHolderRight.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "6")
            {
                UserControl controls = (UserControl)Page.LoadControl("../controls/ucAds.ascx");
                Controls_ucAds control = (Controls_ucAds)controls;
                control.Module_id = objDT.Rows[i]["MODULE_ID"].ToString();
                plHolderRight.Controls.Add(controls);
            }
            else if (objDT.Rows[i]["type_id"].ToString() == "7")
            {
                //UserControl controls = (UserControl)Page.LoadControl("../controls/ucRegistService.ascx");
                //Controls_ucRegistService control = (Controls_ucRegistService)controls;
                //pldHolderLeft.Controls.Add(controls);
            }
        }
    }
}